<?php

include '../../db.php';
$connect = pg_connect($connectionString);
if (!$connect) {
    echo "connect : A connection to the server could not be established!";
    return false;
}
$params = array();
array_push($params, pg_escape_string($_POST["id"]));
array_push($params, pg_escape_string($_POST["cost"]));
array_push($params, pg_escape_string($_POST["price"]));
//array_push($params, pg_escape_string($_POST["quantity"]));



$stmt = pg_prepare($connect, "update_product", "UPDATE warehouse_product SET "
        . "cost=$2"
        . ",price=$3"
        //. ",quantity=$4"
        . " WHERE id = $1 ");

$result = pg_execute($connect, "update_product", $params);

if (!$result) {

    die("Error in SQL query: " . pg_last_error());
}

echo "Data successfully inserted!";

pg_free_result($result);
pg_close($connect);
